<template>
<tl-sub-page :render="render" ref="drawerRef" :visible.sync="visible" :with-header="false" class="tl-drawer" size="95%" :modal-append-to-body="true" :close-on-press-escape="false" :append-to-body="true" @open="open" @close="close" :destroy-on-close="true">
  <div class="project-container"  v-if="isshowline" v-loading="loading" >
    <div class="customer-header">
        <div class="info">
          <img src="/static/images/paojectManager/mpmscore.png" class="logo" style="width: 55px;height: 55px">
          <div class="content" :title="model.projectname">
            <p>
              <b style="overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width: 52%;">{{ projectinfo.projectname }}</b>
            </p>
            <p class="light">
              <span>项目经理：{{ projectinfo.projectmanager }}</span>
            </p>
          </div>
        </div>
        <div class="toolbar">
          <el-button type="danger" icon="el-icon-close" circle @click="doCancelEdit"></el-button>
        </div>
      </div>
    <div style="width:100%">
    <div class="tl-form-line-title" style="height:30px">第一次自评
      <tl-attachment style="float: right;" ref="firstAttachmentRef" :previewMode="false" sourceType="MpmProjectBidScoreFirst" :sourceId="projectinfo.id" :disabled="false" :editable="false"></tl-attachment>
    </div>
        <tl-line :ref="'line1'" :times="'1'" @isloading="isloading" :isapproval="false" :editdisabled="false" :type="'1'" :projectinfo="projectinfo" :title="'商务'" :fromBidApproval="true"></tl-line>
        <tl-line :ref="'line2'" :times="'1'" @isloading="isloading" :isapproval="false" :editdisabled="false" :type="'2'" :projectinfo="projectinfo" :title="'技术'" :fromBidApproval="true"></tl-line>
    </div>
    <div style="width:100%">
    <div class="tl-form-line-title" style="height:30px">第二次自评
      <tl-attachment style="float: right;" ref="secondAttachmentRef" :previewMode="false" sourceType="MpmProjectBidScoreSecond" :sourceId="projectinfo.id" :disabled="false" :editable="false"></tl-attachment>
    </div>
        <tl-line :ref="'line3'" :times="'2'" @isloading="isloading" :isapproval="false" :editdisabled="false" :type="'1'" :projectinfo="projectinfo" :title="'商务'" :fromBidApproval="true"></tl-line>
        <tl-line :ref="'line4'" :times="'2'" @isloading="isloading" :isapproval="false" :editdisabled="false" :type="'2'" :projectinfo="projectinfo" :title="'技术'" :fromBidApproval="true"></tl-line>
    </div>
    <tl-edit ref="editForm" :projectinfo="projectinfo"></tl-edit>
  </div>
  </tl-sub-page>
</template>

<script>
/** mixins */
import { mixin_approval_edit } from '@tapui/mixins/mixin_approval_edit'
/** 子组件 */
import TlRefStakeholder from '../mpmProjectStakeholder/refList'
import TlLine from './indexFrame'
import tlEdit from './edit'
/** 工具类 */
import { putAction, getAction, postAction, deleteAction } from '@tapui/utils/http'
import { formatDate } from '@tapui/utils/date'
/** VUE配置 */
export default {
  mixins: [mixin_approval_edit],
  components: { TlRefStakeholder, TlLine, tlEdit },
  data() {
    return {
      moduleTitle: '评标细则信息表',
      urlPrefix: '/mpm/projectBidScore/',
      url: {
        // 额外的url
        queryBidApprovalInfo: '/mpm/projectBidScore/queryBidApprovalInfo/',
        queryCodeList: '/mpm/projectBidScore/dataCodeList'
      },
      isdisbledtime: true,
      firstedit: true,
      secondedit: false,
      secondshow: true,
      loading: true,
      listindex: 0,
      projectinfo: {},
      size: '95%',
      visible: true,
      isshowline: false
    }
  },
  props: {
    render: {
      default: 'el-drawer',
      type: String
    }
  },
  methods: {
    doCancelEdit() {
      this.visible = false
      this.$emit('close')
      this.$emit('refresh')
    },
    formatDate(date) {
      return formatDate(new Date(date ? date.toString().replace(/\-/g, "/") : date), "yyyy-MM-dd HH:mm")
    },
    queryScoreApprovalInfo() {
      return getAction(this.url.queryBidApprovalInfo, { id: this.id }).then((res) => {
          if (res.success) {
            this.projectinfo = res.result.projectinfo
            this.isshowline = true
            this.isloading()
          } else {
            this.$tap.alert(res.message, 'warning')
          }
        })
    },
    isloading() {
      this.listindex++
      let index = 2
      if (this.listindex >= index) {
        this.loading = false
      }
    },
    open() {
      this.$nextTick((_) => {
        this.queryScoreApprovalInfo()
      })
    }
  },
  created() {
    this.listindex = 0
  }
}
</script>
<style scoped lang="scss">
/deep/.el-drawer {
  padding: 0 15px;
}
/deep/ .el-drawer__body {
  -webkit-box-flex: 1;
  -ms-flex: 1;
  flex: 1;
  overflow: auto;
  border-top: 1px solid rgb(232, 232, 232);
}
</style>
